<?php
require_once (APPLICATION_DIR."/application/model/Alumni_brand.php");
class AlumniBrand
{
	function delBrand($p_intId)
	{
		$objBrand = new DataObjects_Alumni_brand();
		$objBrand -> id = $p_intId;
		
		return $objBrand -> delete();
	}
	
	function updateBrand($p_arrInfo)
	{
                global  $arrArgs;
                $objBrand = new DataObjects_Alumni_brand();
		$objBrand -> info = $p_arrInfo["bInfo"];
		$objBrand -> speak = $p_arrInfo["bSpeak"];	
                $objBrand -> image = $p_arrInfo["image"];			
		$objBrand -> status = $p_arrInfo["status"];		
		$objBrand -> whereAdd("id=" . $arrArgs[1]);
		
		return $objBrand -> update(DB_DATAOBJECT_WHEREADD_ONLY);
	}
	function getInfoBrand($p_intId)
	{
		$objNews = new DataObjects_Alumni_brand();
		$objNews -> selectAdd();
		$objNews -> selectAdd('*');
		$objNews -> whereAdd("id=" . $p_intId);
		$arrTmp = $objNews -> fetchList();
		
		if ( count($arrTmp) )
			return $arrTmp[0];
		else
			return false;
	}

	function addBrand($p_arrInfo)
	{
                        
		$objBrand = new DataObjects_Alumni_brand();
		$objBrand -> info = $p_arrInfo["bInfo"];
		$objBrand -> speak = $p_arrInfo["bSpeak"];	
                $objBrand -> image = $p_arrInfo["image"];			
		$objBrand -> status = $p_arrInfo["status"];	
		$objBrand -> createddate = date("Y-m-d H:i:s");
		
		return $objBrand -> insert();
	}
	
	function getListBrand($p_intStart, $p_intLimit)
	{
		$objBrand = new DataObjects_Alumni_brand();
		
		$objBrand -> limit($p_intStart, $p_intLimit);
		$objBrand -> find();
		return $objBrand;
	}
        
        function getBrandHome(){
            $objBrand = new DataObjects_Alumni_brand();
            $objBrand->selectAdd();
            $objBrand->selectAdd("id, info, speak, image");
            $objBrand->whereAdd();            
            $objBrand->whereAdd("status = 1");
            $objBrand->orderBy();
            $objBrand->orderBy("createddate DESC");           
            $objBrand->limit(5);
            $objBrand->find();
            return $objBrand->fetchList();
        }
}
?>